var t = require("../../../../@babel/runtime/helpers/regeneratorRuntime"), e = require("../../../../@babel/runtime/helpers/asyncToGenerator"), i = require("../../../../common/vendor.js"), n = require("../../../uv-ui-tools/libs/mixin/mpMixin.js"), r = require("../../../uv-ui-tools/libs/mixin/mixin.js"), u = require("./props.js");

require("../../../uv-ui-tools/libs/function/index.js"), require("../../../uv-ui-tools/libs/function/test.js"), 
require("../../../uv-ui-tools/libs/function/digit.js"), require("../../../uv-ui-tools/libs/util/route.js"), 
require("../../../uv-ui-tools/libs/function/debounce.js"), require("../../../uv-ui-tools/libs/function/throttle.js");

var s = {
    name: "uv-grid-item",
    mixins: [ n.mpMixin, r.mixin, u.props ],
    emits: [ "$uvGridItem", "click" ],
    data: function() {
        return {
            parentData: {
                col: 3,
                border: !0
            },
            classes: []
        };
    },
    created: function() {
        this.updateParentData();
    },
    mounted: function() {
        this.init();
    },
    computed: {
        width: function() {
            return 100 / Number(this.parentData.col) + "%";
        },
        itemStyle: function() {
            var t = {
                background: this.bgColor,
                width: this.width
            };
            return this.$uv.deepMerge(t, this.$uv.addStyle(this.customStyle));
        }
    },
    methods: {
        init: function() {
            var t = this;
            i.index.$on("$uvGridItem", function() {
                t.gridItemClasses();
            }), i.index.$emit("$uvGridItem"), this.gridItemClasses();
        },
        updateParentData: function() {
            this.getParentData("uv-grid");
        },
        clickHandler: function() {
            var t, e = this, i = this.name, n = null == (t = this.parent) ? void 0 : t.children;
            n && null === this.name && (i = n.findIndex(function(t) {
                return t === e;
            })), this.parent && this.parent.childClick(i), this.$emit("click", i);
        },
        getItemWidth: function() {
            var i = this;
            return e(t().mark(function e() {
                var n;
                return t().wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        if (n = 0, !i.parent) {
                            t.next = 8;
                            break;
                        }
                        return t.next = 4, i.getParentWidth();

                      case 4:
                        t.t0 = t.sent, t.t1 = Number(i.parentData.col), t.t2 = t.t0 / t.t1, n = t.t2 + "px";

                      case 8:
                        i.width = n;

                      case 9:
                      case "end":
                        return t.stop();
                    }
                }, e);
            }))();
        },
        getParentWidth: function() {},
        gridItemClasses: function() {
            var t = this;
            if (this.parentData.border) {
                var e = [];
                this.parent.children.map(function(i, n) {
                    if (t === i) {
                        var r = t.parent.children.length;
                        (n + 1) % t.parentData.col != 0 && n + 1 !== r && e.push("uv-border-right"), n < r - (r % t.parentData.col == 0 ? t.parentData.col : r % t.parentData.col) && e.push("uv-border-bottom");
                    }
                }), this.classes = e;
            }
        }
    },
    unmounted: function() {
        i.index.$off("$uvGridItem");
    }
}, a = i._export_sfc(s, [ [ "render", function(t, e, n, r, u, s) {
    return {
        a: i.o(function() {
            return s.clickHandler && s.clickHandler.apply(s, arguments);
        }),
        b: i.n(u.classes),
        c: i.s(s.itemStyle)
    };
} ], [ "__scopeId", "data-v-956b17f3" ] ]);

wx.createComponent(a);